<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/23
 * Time: 19:27
 */

namespace App\Http\Controllers\Service;


use App\Http\Controllers\CommonController;
use Illuminate\Support\Facades\Session;
use Symfony\Component\HttpFoundation\Request;

class CarController extends CommonController {

    public function addProduct(Request $request) {
        $proId = $request->input('proId',null);
        if(empty($proId)){
            return responseJson(1,'产品id不能为空');
        }
        if(!Session::has('sp')){
            $productsArr = array();
            $productsArr[$proId] = 1;
            Session::put('sp',$productsArr);
        }else{
            $productsArr = Session::get('sp');
            if(array_has($productsArr,$proId)){
                $productsArr[$proId]+=1;
                Session::put('sp',$productsArr);
            }else{
                $productsArr[$proId] = 1;
                Session::put('sp',$productsArr);
            }
        }
        var_dump(Session::get('sp'));

    }
}